<template>
	<div id="actives">
		<div class="fixed">
			<div class="title flex">
				<div class="title_left">
					<img @click="back" src="../assets/image/return.png" />
				</div>
				<div class="add">
					优惠详情
				</div>
				<div class="title_right" >
					
					<!--<img v-if="flag!=1" @click="showtost" src="../assets/image/shar.png" />-->
				</div>
			</div>

		</div>
		<div class="lists" v-if="flag!=1">

			<div class="list flex"  >

				<div class="qian" v-if="tableData.sort.coupons_type==1">
					<div>{{tableData.sort.coupons_money}}</div>
					<img style="width: 0.4217rem;height: 0.5217rem;" src="../assets/image/qian.png" />
				
				</div>
				<div class="qian" v-if="tableData.sort.coupons_type==2">
				<div>{{tableData.sort.coupons_discount}}</div>
					
				
				
					<img style="width: 0.565217rem;height: 0.8043rem;" src="../assets/image/zhe.png"/>
				</div>
				<div class="xian">
					<img src="../assets/image/fengexain.png" />
				</div>
				<div class="right flex">
					<div v-if="tableData.sort.coupons_type==1">满{{tableData.sort.full_money}}享满减</div>
					<div v-if="tableData.sort.coupons_type==2">满{{tableData.sort.full_money}}享折扣</div>
					
					<div class="data">
						<span>有效期：</span><span>{{active_start_time}}至{{active_end_time}}</span>
					</div>
				</div>

			</div>
			
			<div class="detail">
			   <p>使用说明</p>
			   <div class="shiyong_detail">
			   	{{tableData.sort.use_desc}}
			   </div>
			   <div class="con">
			   	<div class="shopname">
			   	店铺：<span>{{store.store_name}}{{mes.store_name}}</span>
			   </div>
			    <div class="phone">
			   	联系电话：<span style="color: #007AFF;">{{store.store_phone}}</span>
			   </div>
			    <div class="address">
			   地址：<span>{{store.store_address}}</span><img src="../assets/image/dingwei.png"/>
			   </div>
			   </div>
			   
			</div>

		</div>
		
			<div class="lists" v-if="flag==1">

			<div class="list flex"  >

				<div class="qian" v-if="mes.coupons_type==1">
					<div>{{mes.coupons_money}}</div>
					<img style="width: 0.4217rem;height: 0.5217rem;" src="../assets/image/qian.png" />
				
				</div>
				<div class="qian" v-if="mes.coupons_type==2">
				<div>{{mes.coupons_discount}}</div>
					<img style="width: 0.565217rem;height: 0.8043rem;" src="../assets/image/zhe.png"/>
				</div>
				<div class="xian">
					<img src="../assets/image/fengexain.png" />
				</div>
				<div class="right flex">
					<div v-if="mes.coupons_type==1">满{{mes.full_money}}享满减</div>
					<div v-if="mes.coupons_type==2">满{{mes.full_money}}享折扣</div>
					
					<div class="data">
						<span>有效期：</span><span>{{mes.active_start_time}}至{{mes.active_end_time}}</span>
					</div>
				</div>

			</div>
			
			<div class="detail">
			   <p>使用说明</p>
			   <div v-if="mes.use_desc" class="shiyong_detail">
			   	{{mes.use_desc}}
			   </div>
			   <div v-else class="shiyong_detail">
			   暂无使用说明哦~
			   </div>
			   <div class="con">
			   	<div class="shopname">
			   	店铺：<span>{{mes.store_name}}</span>
			   </div>
			    <div class="phone">
			   	联系电话：<span style="color: #007AFF;">{{mes.store_phone}}</span>
			   </div>
			    <div class="address">
			   地址：<span>{{mes.store_address}}</span><img src="../assets/image/dingwei.png"/>
			   </div>
			   </div>
			   
			</div>

		</div>
		
		
   <div class="mask">
		<div class="foot flex">
			<p>分享到</p>
			<div class="shares flex">
				
			
			<div class="share flex">
				<img src="../assets/image/weiixn.png"/>
				<p>微信</p>
			</div>
			<div class="share">
				<img src="../assets/image/pengyouquan.png"/>
				<p>朋友圈</p>
			</div>
			<div class="share" id="local" data-clipboard-action="copy" @click="copy">
				<img  src="../assets/image/copy.png"/>
				<p>复制页面地址</p>
			</div>
			<div class="share" @click="skip_share_ma">
				<img src="../assets/image/erweima.png"/>
				<p>二维码海报</p>
			</div>
</div>
<div class="btn" @click="yincang">
			取消
		</div>
		</div>
		
	</div>

	</div>

</template>

<script>
import Clipboard from 'clipboard';
	export default {
		data() {
			return {
				isActive: 0,
				show: -1,
				activeIndex: -1,
				locations:'',
                link_id:this.$route.query.link_id,
                link_market_store_id:this.$route.query.link_market_store_id,
                link_activeid:this.$route.query.link_activeid,
                active_start_time:"",
               	active_end_time: "",
               	flag:this.$route.query.flag,
               	store:[{
               		store_address:"",
               		store_name:"",
               		store_phone:""
               	}],
               tableData:[{
               	sort:{
               		coupons_money:"",
               		coupons_discount:"",
               		coupons_type:"",
               		full_money:"",
               		use_desc:""
               	},
               	
               }],
               mes:"",
			}
		},
		//在模板渲染成html前调用，即通常初始化某些属性值，然后再渲染成视图
		created: function() {
this.locations = window.location.href
		},
		methods: {
			back() {
				this.$router.go(-1)
			},
			showop(index) {
				let that = this;
				if(that.show == index) {
					that.show = -1; //在这里就将它赋值为-1  由于：-1 !=  index 所以其他内容隐藏 ，被点击的则打开
				} else {
					that.show = index; //这里是把index赋值给isShow，isShow=index则显示
				}

			},
			//查看详情
			creat_c() {
				this.$router.push({
					path: '/Create_coupons'
				});
			},
			showtost() {
				$(".mask").css('display', 'block');

			},
			yincang() {
				$(".mask").css('display', 'none');
			},
			skip_share_ma(){
				this.$router.push({
					path: '/share_ma',
					query:{
						url:window.location.href,
						market_id:"4",
						store_id:"5"
					}
				});
			},
			//复制当前链接地址
			 copy() {
				
				var that = this
				let clipboard = new Clipboard('#local', {
					text: function() {
						return that.locations
					}
				})
				clipboard.on('success', e => {
					this.$message({
						message: '复制成功',
						showClose: true,
						type: 'success'
					})
					// 释放内存
					clipboard.destroy()
				})
				clipboard.on('error', e => {
					this.$message({
						message: '复制失败,',
						showClose: true,
						type: 'error'
					})
					clipboard.destroy()
				})

				   
			},
			 list(){
           	var that=this;
      var qs = require('qs');
			that.$http.post(this.baseURL+"/index.php/waveguest/coupon/enroll_verify_status", qs.stringify({
						"link_id": that.link_id,
						"key":localStorage.getItem("key")
			})).then(response => {
					that.tableData=response.data.data
					console.log(response.data.data)
					that.active_start_time=response.data.data.time.active_start_time
               	that.active_end_time=response.data.data.time.active_end_time
               	that.store=response.data.data.store
					})
					.catch(error => {

					});
    
          },
           skip_detail(){
          		var that=this;
      var qs = require('qs');
			that.$http.post(this.baseURL+"/index.php/waveguest/coupon/make_coupons_detail", qs.stringify({
			        	"link_market_store_id":that.link_market_store_id,
						"link_activeid":that.link_activeid,
						"key":localStorage.getItem("key")
					
				})).then(response => {
					
					that.mes=response.data.data
				     console.log(that.mes)
					})
					.catch(error => {

					});
          }
			
		},
		mounted() {
if(this.flag=="1"){
	this.skip_detail()
}else{
	this.list()
}
		},
	}
</script>

<style>
.el-message {
		min-width: 4rem;
		top: 40% !important;
	}
</style>
<style scoped="scoped">
	#actives {
		background: #F5F6FA;
		height: 100%;
		width: 100%;
		position: fixed;
	}
		
	.title {
		width: 90%;
		padding: 0 5% 0 5%;
		height: 2rem;
		font-size: 0.7193rem;
		background: white;
		align-items: center;
	}
	
	.title div {
		width: calc(100%/3);
		align-items: center;
	}
	
	.title>div:nth-child(2) {
		text-align: center;
	}
	
	
	
	.title_left {
		width: 0.67391rem;
		height: 0.67391rem;
	}
	
	.title_left>img {
		width: 0.67391rem;
		height: 0.67391rem;
	}
	
	.title_right {
		width: 0.9rem;
		height: 0.9rem;
	}
	
	.title_right>img {
		width: 0.9565rem;
		height: 0.9365rem;
		float: right;
	}
	
	.lists {
		margin-top: 2rem;
		padding-top: 1rem;
	}
	
	.list {
		/*border: 1px solid white;*/
		margin-bottom: 0.5rem;
		margin-left: 0.5rem;
		margin-right: 0.5rem;
		padding-right: 1rem;
		padding-left: 1rem;
		background: url(../assets/image/quan_bg.png) no-repeat;
		background-size: 100%;
		border-radius: 10px;
		height: 5.8478rem;
		justify-content: space-between;
		align-items: center;
	}
	.fixed {
		position: fixed;
		top: 0;
		background: white;
		width: 100%;
		max-width: 640px;
	}
   .list>.qian{
   	font-size: 2.57826rem;
   	color: white;
   	position: relative;
   }
    .list>.qian>img{
   	
   	position: absolute;
   	right: -0.5rem;
   	top: 0;
   }
   .list>.right{
   	font-size: 1.3043rem;
   	color: white;
   flex-direction: column;
   }
   .list>.xian>img{
   width: 0.07rem;
   height: 1.7391rem;	
   }
   .list>.right>.data{
   	padding-top: 0.5rem;
   	font-size: 0.5rem;
   	color: white;
  
   }
.detail{
	background: white;
	margin-bottom: 0.5rem;
		margin-left: 0.5rem;
		margin-right: 0.5rem;
		padding: 1rem;
		border-radius: 10px;
		font-size: 0.60869rem;
		font-weight: 600;
}
	.shiyong_detail{
		font-size: 0.5652rem;
		color: #868E91;
		font-weight: 400;
		padding-top: 0.3rem;
	}
	.con{
		margin-top: 1.1rem;
		padding-bottom: 1rem;
	}
	
	.con>div{
		padding-bottom: 0.3rem;
	}
	.con span{
		color: #868E91;
		font-weight: 400;
	}
	.con>div>img{
	 width: 0.7608rem;
	 height: 0.7608rem;
	 padding-left: 0.3rem;
	}
	.mask {
		position: fixed;
		width: 100%;
		left: 0;
		top: 0;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.4);
		transition: all 0.2s ease-in;
		z-index: 999;
		display: none;
		
	}
	.foot{
		background: #F5F6FA;
		position: fixed;
		bottom:0;
		width: 100%;
		border-radius: 0.4rem 0.4rem 0rem 0rem;
		height: 8.7391rem;
		z-index: 99999;
		flex-direction: column;
	}
	.foot>p{
		font-size: 0.56522rem;
		color: #868E91;
		height: 2.565217rem;
		line-height: 2.565217rem;
		padding-left: 1.5rem;
		
	}
	.shares{
		justify-content: space-around;
		
	}
	.share{
		justify-content: center;
		align-items: center;
		flex-direction: column;
		text-align: center;
		width: 4rem;
	}
	.share>img{
		width: 1.7391rem;
		height: 1.7391rem;
	}
	.share>p{
		font-size: 0.56522rem;
		color: #3E474E;
		padding-top: 0.3rem;
	}
	.btn{
		position: fixed;
		bottom: 0;
		width: 100%;
		background: white;
		height: 2rem;
		line-height: 2rem;
		text-align: center;
		color: #3E474E;
		font-size: 0.6087rem;
	}
</style>